package com.example.administrator.yuejian_15.activity;

import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;


import com.example.administrator.yuejian_15.R;
import com.example.administrator.yuejian_15.adapter.PxAdapter;
import com.example.administrator.yuejian_15.bean.PxBean;
import com.example.administrator.yuejian_15.listener.ListListener;
import com.example.administrator.yuejian_15.model.PxCnModel;

import java.util.List;

public class PxCnActivity extends BaseActivity implements View.OnClickListener {
    ImageView cnpx_fh;
    RecyclerView rv_cnpxlist;
    List<PxBean> items;

    @Override
    void initView() {
        setLayout_file(R.layout.activity_px_cn);

        cnpx_fh=(ImageView)findViewById(R.id.cnpx_fh);
        rv_cnpxlist=(RecyclerView)findViewById(R.id.rv_cnpxlist);


        PxCnModel pxCnModel = new PxCnModel();
        pxCnModel.getCnList(pxBeanListListener);
    }

    @Override
    void initEvent() {
        cnpx_fh.setOnClickListener(this);

    }

    @Override
    void initDate() {

    }

    ListListener<PxBean> pxBeanListListener=new ListListener<PxBean>() {
        @Override
        public void onResponse(List<PxBean> list) {
            LinearLayoutManager linearLayoutManager=new LinearLayoutManager(PxCnActivity.this);
            linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
            rv_cnpxlist.setLayoutManager(linearLayoutManager);
            items=list;
            PxAdapter pxAdapter=new PxAdapter(PxCnActivity.this,items,R.layout.item);
            rv_cnpxlist.setAdapter(pxAdapter);
            rv_cnpxlist.setItemAnimator(new DefaultItemAnimator());
        }

        @Override
        public void onFail(String msg) {

        }
    };

    @Override
    public void onClick(View view) {
        switch (view.getId()){
            case R.id.cnpx_fh:
                finish();
                break;
        }
    }
}
